/*Copyright 2014 Rajesh Putta http://www.codesnippets4all.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
* 
*/

package com.codesnippets4all.jthunder.core.config.handlers;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

import org.xml.sax.Attributes;

import com.codesnippets4all.jthunder.core.utils.Utility;

/*
 * @author Rajesh Putta
 */
public class PhaseConfig implements Serializable{

	private static final long serialVersionUID = 3089173464026688341L;
	
	private String name=null;
	
	private String depends=null;

	private TriggersConfig triggersConfig=null;
	
	private Map<String, TaskConfig> config=new LinkedHashMap<String, TaskConfig>();
	
	private Configuration configuration;
	
	public void addPhase(Attributes attributes)
	{
		this.name=attributes.getValue("name");
		
		this.depends=attributes.getValue("depends");
		
		if(Utility.isNullOrEmpty(this.name))
			throw new IllegalArgumentException("phase-config element should consists of name attribute configured...");
	}
	
	public void addTaskConfig(TaskConfig taskConfig)
	{
		this.config.put(taskConfig.getName(), taskConfig);
	}
	
	public Map<String, TaskConfig> getConfig()
	{
		return this.config;
	}
	
	public void setConfiguration(Configuration configuration) {
		this.configuration = configuration;
	}
	
	public Configuration getConfiguration() {
		return configuration;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	
	public void setDepends(String depends) {
		this.depends = depends;
	}
	
	public String getDepends() {
		return depends;
	}
	
	public void setTriggersConfig(TriggersConfig triggersConfig) {
		this.triggersConfig = triggersConfig;
	}
	
	public TriggersConfig getTriggersConfig() {
		return triggersConfig;
	}
}
